# -*- coding: utf-8 -*-
# @Time    : 2022/7/16 16:42
# @Author  : haichuan
# @Email   : 2263126410@163.com
# @File    : xtbs_grzl_xgpage.py
# @Software: PyCharm

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.support.select import Select
from pages.denglu_page import Deng_BasePage


class XgGrzlpags(Deng_BasePage):
    '''修改个人资料(定位器）'''
    driver=webdriver.Chrome
    url = "http://localhost/crm"
    grzl = (By.CSS_SELECTOR, 'li.dropdown:nth-child(6) > ul:nth-child(2) > li:nth-child(3) > a:nth-child(1)')
    count_png = (By.ID, 'file_upload')
    xg_username = (By.CSS_SELECTOR, '.table > tbody:nth-child(3) > tr:nth-child(4) > td:nth-child(2) > input:nth-child(1)')
    xg_username_key = "bg"
    xg_mima = (By.ID, 'password')
    user_lb = (By.ID, 'category_id')
    zhanghao = (By.ID, 'status')
    bumen = (By.ID, 'department')
    gangw = (By.ID,'role')
    xb= (By.XPATH, '/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[10]/td[2]/input[2]')
    email = (By.NAME, 'email')
    phone_name = (By.NAME, 'telephone')
    name_lxdz= (By.NAME, 'address')
    save = (By.CSS_SELECTOR, '.table > tfoot:nth-child(2) > tr:nth-child(1) > td:nth-child(2) > input:nth-child(1)')

    def jr_grzl(self):
        '''点击个人资料'''
        self.driver.find_element(*self.grzl).click()
    def user_log(self,jpg):
        "上传头像"
        self.driver.find_element(*self.count_png).send_keys(jpg)
    def xg_name(self,xgname):
        '''修改用户名'''
        self.driver.find_element(*self.xg_username).clear()
        self.driver.find_element(*self.xg_username).send_keys(*xgname)
    def xg_password(self,password):
        "修改密码"
        self.driver.find_element(*self.xg_mima).clear()
        self.driver.find_element(*self.xg_mima).send_keys(password)
    def xg_yhlb(self):
        '''修改用户类别'''
        user_lb_se = self.driver.find_element(*self.user_lb)
        Select( user_lb_se ).select_by_index(0)
    def xg_zhzt(self):
        '''修改账号状态'''
        zhanghao_se=self.driver.find_element(*self.zhanghao)
        Select(zhanghao_se).select_by_index(1)
    def xg_bum(self):
        '''修改部门'''
        bumen_se=self.driver.find_element(*self.bumen )
        Select(bumen_se).select_by_index(1)

    def xg_gw(self):
        '''修改岗位'''
        gangw_se=self.driver.find_element(*self.gangw)
        Select(gangw_se).select_by_visible_text("CEO")

    def xg_xb(self):
        '''修改性别'''
        # xz_xb=\
        self.driver.find_element(*self.xb).click()
        # Select(xz_xb).select_by_index(1)



    def xg_email(self,email):
        '''修改邮箱'''
        self.driver.find_element(*self.email).clear()
        self.driver.find_element(*self.email).send_keys(email)

    def xg_phone(self,phone):
        '''修改手机'''
        self.driver.find_element(*self.phone_name).clear()
        self.driver.find_element(*self.phone_name).send_keys(phone)

    def xg_lxdz(self,lxdz):
        '''修改联系地址'''
        self.driver.find_element( *self.name_lxdz ).clear()
        self.driver.find_element(*self.name_lxdz).send_keys(lxdz)

    def baocun(self):
        '''保存按钮'''
        self.driver.find_elements(*self.save).click()

